$(document).ready(function () {
    $("#genderSelect").selectpicker();

    toastr.options = {
        "closeButton": true,
        "debug": false,
        "progressBar": true,
        "positionClass": "toast-top-right",
        "onclick": null,
        "showDuration": "400",
        "hideDuration": "1000",
        "timeOut": "7000",
        "extendedTimeOut": "1000",
        "showEasing": "swing",
        "hideEasing": "linear",
        "showMethod": "fadeIn",
        "hideMethod": "fadeOut"
    }

});

/**
 * 保存一个商品分类
 */
function saveEmployee(){
    let $id=$('#id')
    let $name = $('#name')
    let employee={
        name:$name.val(),
        gender:$('#genderSelect').val(),
        telephone:$('#telephone').val(),
        birthday:$('#birthday').val(),
        backup:$('#backup').val()
    }
    if ($id.val()!==null){
        employee.id=$id.val()
    }
    if (!employee.name){
        toastr.error('姓名输入不能为空！','提示：')
        $name.focus()
        return;
    }
    $.ajax({
        url: "/admin/info/employee/save",
        type: "POST",
        data: JSON.stringify(employee),
        contentType: "application/json;charset=UTF-8",
        dataType: "text",
        success: function (resp) {
            let parse = JSON.parse(resp)
            if (parse.data) {
                toastr.success(parse.message, "提示");
                setTimeout(function (){
                    location.reload()
                },2000)
            } else {
                toastr.error(parse.message, '提示')
            }
        }
    });

}
